/**
 * LocalStorage操作相关类
 */
export class LocalStorage {

  private static readonly token = "token";
  private static readonly menus = "menus";

  static getToken(): string {
    return localStorage.getItem(this.token);
  }

  static saveToken(token): void {
    localStorage.setItem(this.token, token);
  }

  static isToken(): boolean {
    if (localStorage.getItem(this.token) && localStorage.getItem(this.token) != "")
      return true;
    else
      return false;
  }

  static removeToken(): void {
    localStorage.clear();
  }

  static getInfoObject(): any {
    return window.loginUserInfo;
  }

  static isButton(id): boolean {
    let allButtons = window.bottons;
    let newId = "b" + id;
    if(allButtons[newId]){
      return allButtons[newId] === "1";
    }
    else {
      return true;
    }
  }

  static getMenus(): string {
    return localStorage.getItem(this.menus);
  }

  static saveMenus(menus): void {
    localStorage.setItem(this.menus, menus);
  }

}
